<script>

  /*
    创建一个Person类，构造方法的参数有名字name和年龄age
    有实例方法 compareAge用来比较年龄
    compareAge返回字符串
  
    如
    ```js
    let p1 = Person("张三", 24)
    let p2 = Person("李四", 36)
    let p3 = Person("王五", 24)
  
    p1.compareAge(p2) // "李四比我大"
    p2.compareAge(p1) // "张三比我小"
    p1.compareAge(p3) // "王五和我一样大"
    ```
  */

  // ？？你的代码
  class Person {
    name
    age
    constructor(name, age) {
      this.name = name
      this.age = age
    }
    compareAge(p) {
      if (this.age > p.age) {
        return `${p.name}比我小`
      } else if (this.age < p.age) {
        return `${p.name}比我大`
      } else if (this.age === p.age) {
        return `${p.name}和我一样大`
      }
    }
  }

  let p1 = new Person("张三", 24)
  let p2 = new Person("李四", 36)
  let p3 = new Person("王五", 24)


  p1.compareAge(p2) // "李四比我大"
  p2.compareAge(p1) // "张三比我小"
  p1.compareAge(p3) // "王五和我一样大"
  console.log(p1.compareAge(p2));
  console.log(p2.compareAge(p1));
  console.log(p1.compareAge(p3));
</script>